菜单切换
FACESOHO知行者
心灵
记录
远方
赞赏工具
源代码:
点击运行
保存
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Vue.js 动态调节样式</title> <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script> </head> <body> <div id="app"> <div v-bind:style="{ color:activeColor, fontSize:fontSize + 'px' }">顽石之中良玉隐焉,寒灰之中星火寓焉。</div> <button v-on:click="fontSize --">-</button> <button v-on:click="fontSize ++">+</button> {{fontSize}} </div> <script> new Vue({ el:'#app', data:{ activeColor:'green', fontSize:22 } }) </script> </body> </html>
运行结果